#ifndef EQUALIZERGROUP_H
#define EQUALIZERGROUP_H

#include <QObject>

class EqualizersGroup : public QObject
{
    Q_OBJECT
public:
    explicit EqualizersGroup(QObject *parent = nullptr);
    ~EqualizersGroup();

    struct FilterParam{
        double b0;
        double b1;
        double b2;
        double a1;
        double a2;
    };
    enum FilterType{
        Lowpass=1,
        Hightpass,
        Bandpass,
        Peak,
        Notch,
        Lowshelf,
        Highshelf,
    };
    struct EQ_Info{
        double cf;
        double gain;
        double q;
        double cf_max;
        double cf_min;
        double gain_max;
        double gain_min;
        double q_max;
        double q_min;
        FilterType type;
        FilterParam param;
        QList<double> freqResp;
    };
    void addFilter(FilterType type, double cf, double gainDB, double q);
    int getFilterCount(void);
    void setEqualizerGroupSampleRate(double sample);
    void setFilterCenterFrequency(int num, double cf);
    void setFilterCenterFrequencyMax(int num, double max);
    void setFilterCenterFrequencyMin(int num, double min);
    void setFilterGainDB(int num, double gainDB);
    void setFilterGainDBMax(int num, double max);
    void setFilterGainDBMin(int num, double min);
    void setFilterQ(int num, double q);
    void setFilterQMax(int num, double max);
    void setFilterQMin(int num, double min);
    void setFilterGroupStartFrequency(double sf);
    void setFilterGroupEndFrequency(double ef);
    void setFilterFrequencyResponseInterval(double iv);
    void setFilterCenterFrequencyAll(double cf);
    void setFilterCenterFrequencyMaxAll(double max);
    void setFilterCenterFrequencyMinAll(double min);
    void setFilterGainDBAll(double gainDB);
    void setFilterGainDBMaxAll(double max);
    void setFilterGainDBMinAll(double min);
    void setFilterQAll(double q);
    void setFilterQMaxAll(double max);
    void setFilterQMinAll(double min);
    void setFilterType(int num,FilterType type);

    double getEqualizerGroupSampleRate(void);
    int getFilterType(int num);
    double getFilterCenterFrequency(int num);
    double getFilterCenterFrequencyMax(int num);
    double getFilterCenterFrequencyMin(int num);
    double getFilterGainDB(int num);
    double getFilterGainDBMax(int num);
    double getFilterGainDBMin(int num);
    double getFilterQ(int num);
    double getFilterQMax(int num);
    double getFilterQMin(int num);
    double getFilterGroupStartFrequency(void);
    double getFilterGroupEndFrequency(void);
    double getFilterFrequencyResponseInterval(void);
    void updateEqualizer(int num);
    QList<double> &getFilterFrequencyResponse(int num);
    void clear(void);

private:
    const double pi = 3.141592653589793;
    double sampleRate = 48000;
    double freqRespInterval = 5;
    double freqRespStartFreq = 20;
    double freqRespEndFreq = 24000;
    QList<EQ_Info *> eqInfo;

protected:
    QScopedPointer<EqualizersGroup> d_ptr;


signals:

};

#endif // EQUALIZERGROUP_H
